package cn.edu.xmu.oomall.aftersale.model.bo;

import java.util.HashMap;
import java.util.Map;

/**
 * @author X-Raymond
 * @date 2021/12/8
 */

public enum AftersaleState {
    //新建态
    BEGIN(0, "新建态"),
    //等待买家发货
    WUDELIVER(1, "等待买家发货"),
    //买家已发货
    UDELIVER(2, "买家已发货"),
    //等待退款
    WREFUND(3, "等待退款"),
    //等待卖家发货
    WSDELIVER(4, "等待卖家发货"),
    //卖家已发货
    SDELIVER(5, "卖家已发货"),
    //已结束
    FINISH(6, "已结束"),
    //已取消
    CANCEL(7, "已取消"),
    //待支付
    WPAY(8, "待支付");

    private static final Map<Integer, AftersaleState> STATE_MAP;

    static { //由类加载机制，静态块初始加载对应的枚举属性到map中，而不用每次取属性时，遍历一次所有枚举值
        STATE_MAP = new HashMap();
        for (AftersaleState enum1 : values()) {
            STATE_MAP.put(enum1.code, enum1);
        }
    }

    private int code;
    private String description;

    AftersaleState(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public static AftersaleState getTypeByCode(Integer code) {
        return STATE_MAP.get(code);
    }

    public Integer getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
